//
//  BLEManager.h
//  HDPatrolSystem
//
//  Created by hengdaliuyi on 16/3/28.
//  Copyright © 2016年 hengdawb. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <CoreBluetooth/CoreBluetooth.h>

@protocol BLEMangerDelegate <NSObject>
/**
 判断是否连接上智慧笔
 */
-(void)bleMangerConnectedPeripheral :(BOOL)isConnect;

/**
 断开智慧笔
 */
-(void)bleMangerDisConnectedPeripheral :(CBPeripheral *)_peripheral;
@optional
-(void)bleMangerReceiveDataPeripheralData :(NSData *)data from_Characteristic :(CBCharacteristic *)curCharacteristic;

@end

@protocol cbDiscoveryManagerDelegate <NSObject>
@optional
- (void) discoveryDidRefresh;
- (void) bluetoothStateUpdatedToState:(BOOL)state;

@end

@interface BLEmanager : NSObject<CBCentralManagerDelegate>
{
    CBCentralManager *_m_manger;
    CBPeripheral     *_m_peripheral;
    NSMutableArray *m_array_peripheral; //存放智慧笔
}

@property (nonatomic,  copy ) NSMutableArray             *m_array_peripheral;
@property (nonatomic,strong ) CBCentralManager           *m_manger;
@property (nonatomic,strong ) CBPeripheral               *m_peripheral;
@property (weak,  nonatomic ) id<BLEMangerDelegate>      mange_delegate;
@property (nonatomic, assign) id<cbDiscoveryManagerDelegate> cbDiscoveryDelegate;
@property (nonatomic, assign) BOOL                       cbCentralPoweredOn;

+(BLEmanager *)shareInstance;

- (void) startScanning;

- (void) stopScanning;

//- (void) initCentralManger;

//- (void) refreshPeripherals;

//- (void) connectPeripheral:(CBPeripheral*)peripheral CompletionBlock:(void (^)(BOOL success, NSError *error))completionHandler;

//- (void) disconnectPeripheral:(CBPeripheral*)peripheral;
@end


